package com.inossem.warehousestorage_inossem.activity.out_storage;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.inossem.utils.listener.NoDoubleClickListener;
import com.inossem.warehousestorage_inossem.R;
import com.inossem.warehousestorage_inossem.activity.base.BaseActivity;
import com.inossem.warehousestorage_inossem.activity.out_storage.extra.OutStorageExtra;
import com.inossem.warehousestorage_inossem.utils.ActivityUtils;
import com.zhy.android.percent.support.PercentRelativeLayout;

public class OutStorageManageActivity extends BaseActivity {

    TextView title;

    private PercentRelativeLayout pickingOutStorage, saleOutStorage, returnOutStorage , allocatingOutStorage , otherOutStorage;

    private boolean mFlag = false;

    @Override
    protected void onCreateImpl(Bundle savedInstanceState) {
        setContentView(R.layout.activity_out_storage_manage);
        initView(OutStorageManageActivity.this);
    }

    @Override
    protected void onResumeImpl() {
        initData(OutStorageManageActivity.this);
    }

    private void initView(Activity activity) {
        title = (TextView) activity.findViewById(R.id.headerTitle);
        pickingOutStorage = (PercentRelativeLayout) activity.findViewById(R.id.pickingOutStorage);
        saleOutStorage = (PercentRelativeLayout) activity.findViewById(R.id.saleOutStorage);
        returnOutStorage = (PercentRelativeLayout) activity.findViewById(R.id.returnOutStorage);
        allocatingOutStorage = (PercentRelativeLayout) activity.findViewById(R.id.allocatingOutStorage);
        otherOutStorage = (PercentRelativeLayout) activity.findViewById(R.id.otherOutStorage);
    }

    private void initData(Activity activity) {
        title.setText(activity.getResources().getString(R.string.activity_out_storage_manage_title));
        ActivityUtils.initBackAndFunction(activity, R.string.activity_main_title_short, new NoDoubleClickListener() {
            @Override
            public void onNoDoubleClick(View v) {
                finish();
            }
        });
        getExtra(activity);
        if (mFlag) {
//            Intent intent = new Intent(activity, UpFrame_ManageActivity.class);
//            startActivity(intent);
//            finish();
        } else {
            pickingOutStorage.setOnClickListener(new NoDoubleClickListener() {
                @Override
                public void onNoDoubleClick(View v) {
                    Intent intent = new Intent(activity, OutStoragePickingListActivity.class);
                    startActivity(intent);
                }
            });
            saleOutStorage.setOnClickListener(new NoDoubleClickListener() {
                @Override
                public void onNoDoubleClick(View v) {
                    Intent intent = new Intent(activity, OutStorageSaleListActivity.class);
                    startActivity(intent);
                }
            });
            returnOutStorage.setOnClickListener(new NoDoubleClickListener() {
                @Override
                public void onNoDoubleClick(View v) {
                    Intent intent = new Intent(activity, OutStorageReturnListActivity.class);
                    startActivity(intent);
                }
            });
            allocatingOutStorage.setOnClickListener(new NoDoubleClickListener() {
                @Override
                public void onNoDoubleClick(View v) {
                    Intent intent = new Intent(activity, OutStorageAllocatingListActivity.class);
                    startActivity(intent);
                }
            });
            otherOutStorage.setOnClickListener(new NoDoubleClickListener() {
                @Override
                public void onNoDoubleClick(View v) {
                    Intent intent = new Intent(activity, OutStorageOtherIndexActivity.class);
                    startActivity(intent);
                }
            });
        }
    }

    private void getExtra(Activity activity) {
        mFlag = activity.getIntent().getBooleanExtra(OutStorageExtra.FLAG, false);
    }

}
